/**
 * 
 */
package net.bingosoft.common.upload;

/**
 * 表示一个上传到服务器上的文件
 * @author elvis
 */
public class UploadFile {

    /** 唯一ID */
    private String id;
    
    /** 客户端上传文件的全路径 */
    private String clientPath;

    /** 服务器端保存上传文件的目录 */
    private String uploadFolder;
    
    /** 服务器端生成的文件存储目录，不包括uploadFolder */
    private String serverFolder;
    
    /** 服务器端文件名 */
    private String serverName;
    
    /** 服务器文件保存路径，由uploadFolder + serverFolder + serverName */
    public String getServerPath() {
        return getUploadFolder() + getServerFolder() + getServerName();
    }

    /** 客户端文件名 */
    public String getClientName() {
        if(null != clientPath){
            int index1 = clientPath.lastIndexOf("/");
            int index2 = clientPath.lastIndexOf("\\");
            if(index2 > index1){
                index1 = index2;
            }
            return clientPath.substring(index1+1,clientPath.length()); 
        }
        return null;
    }    

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }
    
    public String getClientPath() {
        return clientPath;
    }

    public void setClientPath(String clientPath) {
        this.clientPath = clientPath;
    }

    public String getServerName() {
        return serverName;
    }

    public void setServerName(String serverName) {
        this.serverName = serverName;
    }

    public String getUploadFolder() {
        return uploadFolder;
    }

    public void setUploadFolder(String uploadFolder) {
        this.uploadFolder = uploadFolder;
    }

    public String getServerFolder() {
        return serverFolder;
    }

    public void setServerFolder(String serverFolder) {
        this.serverFolder = serverFolder;
    }
}
